Repository navigation
LDtk and Sprite Fusion levels, on a tile map core shared with Tiled - #1914
Merged
Merged
Conversation
On a machine with a WebGPU adapter, 14 tests of mask-effect-image.spec.js failed: the pixel helper's WebGPU branch called a method the renderer does not have, and the WebGPU application made in the same file took the place of the Canvas one the later tests use. - helpers/pixels.js: grabFrame() reads a whole frame on any backend (a texture-to-buffer copy on WebGPU), and drawOffscreen() has a WebGPU renderer draw into a texture of its own, which reads back the same on a headless software adapter, where a canvas texture cannot be presented - the drawing checks move to helpers/mask-effect-checks.js, and take each frame once, as it is drawn: an application's loop draws over it while a test awaits - the WebGPU checks get a spec file of their own, with a projection set Verified with a software WebGPU adapter: the 12 WebGPU checks pass, and skip as before where there is no adapter. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
An isometric tile layer can take the "shader" render mode, on WebGL 2 and on WebGPU: one quad for the view, the fragment shader finding each pixel's tile. For a pixel it walks the cells whose tile image could cover it, front to back (the reverse of the order TMXIsometricRenderer draws in), and keeps the first texel that is not transparent, so tall tiles overlap the rows behind them as on the CPU path. - shaders: the part every orientation shares (index and animation lookups, flips, atlas sampling) is split from the orthogonal part, in GLSL and in WGSL; the isometric part adds only its cell maths - renderers: a TMXLayerGPURenderer base per backend, with the orthogonal and isometric ones on top; the part of a layer a view shows is computed in one module both backends read (gpu/tmxlayer_region.js) - TMXLayer: an isometric layer is eligible when its tiles come from one tileset (they overlap, and a pass draws one tileset), an image one, with tiles within the shader's bounds; a tileoffset is supported. A tile of another tileset set at run time moves the layer back to the CPU path - tests: helpers/tile-layer-compare.js draws a layer through the CPU and the GPU path, with the whole engine in between, and compares the frames Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
…rence (#1897) The GPU path took the first texel that was not transparent, front to back. With drawn art that is wrong wherever tiles overlap, which on an isometric map is everywhere: the soft edge of a tile showed the background in place of the tile behind it. Each texel now goes behind the ones before it until the fragment is opaque, which is what drawing the tiles one over the other comes to. The orthogonal shader shares it, for tiles larger than the grid. Found by a scenario suite that draws every case through the CPU renderer and the GPU one, on WebGL and on WebGPU, and compares both with a reference painted with no engine at all. It also found, and this fixes: - the isometric CPU renderer left out tiles by the first tileset's size, and by no tileset's `tileoffset` - the orthogonal CPU renderer widened the wrong side of the view for tiles taller than the grid - the orthogonal GPU quad cut tiles larger than the grid above the first row and right of the last column - a tile that is not square, flipped diagonally, is wrong on the GPU path: such a layer is left to the CPU renderer Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
…1897) From an independent review of the isometric GPU path: - a grid of odd size, and a blend mode other than the normal one, are left to the CPU renderer: the first stands half the tiles half a pixel off, the second shows where tiles overlap - a tileset image with no margin after its last tiles was counted a column short (the orthogonal path too) - a layer asked for "shader" by hand after it was found unfit for it is drawn tile by tile, where an isometric one drew nothing - the tile shader declares full precision itself, and finds a tile's place in the atlas in whole numbers Faster per fragment: what sampling needs of a fragment is taken once instead of for every cell tried, a cell whose tile cannot reach the fragment is dropped before its index is fetched, and the isometric walk skips the rows outside the map. What differs with a map's orientation is in one module for both backends (`gpu/tmxlayer_orientation.js`: the region, the tilesets, the shader's limits, which the layer's checks read too), so each backend has one renderer class and the shader text. `tests/tmxlayer_bench.spec.js` measures the main thread's share of a frame tile by tile and on the GPU path, orthogonal and isometric. Changelog, API docs and the tilemaps skill. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
…ir tiles reach Two gaps the reference picture of the tile layer tests had to work around (#1897), on every renderer and render mode. A tile layer ignored its offset in Tiled (`offsetx`, `offsety`) and its own `pos`: it was always drawn at the map's origin, where image layers followed theirs. The offset now goes into `pos`, and the layer draws its tiles, and `getTile()` finds them, where `pos` says. A layer was skipped once its grid left the view, though tiles larger than a cell, or moved by a `tileoffset`, still reached in: the tops of tall tiles vanished above the map. The layer's bounds now cover how far its tiles reach; its `width` and `height` stay the grid's. Tests written first and seen to fail: both paths against the reference on WebGL and WebGPU (offset layers, several layers, an infinite map, a layer moved at run time, views that hold only the reach), and on the Canvas renderer tile by tile and baked, with `getTile`, the bounds, and staggered and hexagonal maps. The reference no longer leaves out a layer whose grid is out of view. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
Both are one geometry, on the base the isometric path shares: lines of cells a row height apart, every other one shifted by a column width, along the map's rows or its columns. One shader chunk (GLSL and WGSL) and one region function draw both; a hexagonal map's cells are longer by its side length, which is in the two lengths the shader is given (in what was the padding of the WGSL uniform block). The layer's checks are those of an isometric layer: one tileset, tiles up to 4 cells wide and 8 tall, a grid of even size. The CPU renderer of these maps is fixed first, as the reference of the tests showed it away from Tiled: its drawing loop hung a tile larger than its cell from the top of the cell and ignored the tileset's `tileoffset`, where its own `drawTile` (and Tiled) stand the tile on the cell and move it by the offset; and it left out tiles of a large tileset along the edges of the view. Tests: the reference paints staggered and hexagonal maps; 24 scenes (both orientations, either axis, either index, three kinds of tiles) on the Canvas renderer tile by tile and baked, and 38 scenarios on WebGL and WebGPU through both paths, with soft edges, flips, animation, layer offsets, infinite maps, setTile and the fallbacks. The comparison of the two paths moves to the shared test helper. Changelog, API docs and the tilemaps skill. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
A layer reads the camera's view in its own coordinates. It is handed the view in the world's, and is drawn where its ancestors put it: a map centred in the view by moving the world (`level.load`) lost the tiles reaching above or left of its grid on the GPU and baked paths, and a layer in a moved container lost tiles tile by tile. A layer keeps track of whether the shader path can still draw it whichever way it is drawn: a tile of a second tileset set while the layer was switched to "perTile" by hand was left undrawn once it was switched back. A tile layer's bounds are its grid's again. What its tiles reach past the grid is asked for separately (`getDrawBounds`, read by `Camera2d#isVisible`): growing `getBounds()` moved what read it as the map's area. Pathfinding plugin: a grid from a tile layer stands where the layer was moved to (its offset in Tiled, its `pos`), as the layer is now drawn. One helper cuts the view to a layer's tiles for the isometric and the staggered regions; stale comments and the docs corrected. Tests: a layer in a centred map and in a moved container, on Canvas, WebGL and WebGPU, in every render mode and orientation, against the reference; render modes switched by hand with tiles set in between. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
Probes written to break the tile layer code, each against the reference picture, and what they found: - An orthogonal layer whose tiles are larger than the grid lay them over each other in the wrong order on the GPU when they came from more than one tileset (a pass per tileset) or the map's render order was not "right-down": such a layer is drawn tile by tile. - A layer with more columns or rows than the largest texture drew nothing on the GPU: drawn tile by tile. - A hexagonal map whose side leaves an odd number of pixels of a cell is laid out on whole pixels, as Tiled's own numbers are; and so drawn by the GPU too. The baked canvas of a staggered or hexagonal map of odd tile size was a pixel short. - The isometric CPU renderer left out tiles narrower than half a cell at the right edge of the view. - A camera with an offset over a moved world: the layer asked a plain rectangle, in place of the camera, whether it was the default one. - A container with a size of its own (a level loaded into one) is in view by its bounds before its layers are asked: it is told how far their tiles reach. - A layer taken out of its container and added again threw; a tile its tileset's image does not hold threw every frame tile by tile, and is now left undrawn on both paths. The probes are kept as tests (`tile-layer-edge-cases.js`, on WebGL and WebGPU), with the reference taught the orthogonal render orders and Tiled's whole numbers for hexagons. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
Staggered and hexagonal maps are laid out with Tiled 1.10's own numbers: what a side leaves of a tile is halved in whole numbers, and the cell a tile stands on is made of those halves, a pixel smaller than a tile of odd size. A map of odd sizes is on whole pixels, so the GPU path takes it; the shader's pixels are measured from as much lower as the cell is shorter. A painter written apart from the tests' reference, from Tiled's source, agrees with both paths. A container holds the tile layers that can draw outside its bounds, and is in view as far as they do: their tiles' reach, a layer's offset, an infinite map's first chunks. (A level loaded into a container gives it the map's size, and the camera asks the container before its layers.) A tile its tileset's image does not hold is left undrawn by `drawTile` too: setting one on a baked layer threw. Tests, from the gaps the audit listed: pictures for the grids of odd sizes, where only the render mode was looked at; flips on hexagons; an infinite map with chunks at odd coordinates; a layer offset and an infinite map in a container; a sliver of 1, 2 and 5 pixels of each orientation at each edge of the view, and a pixel out of sight; `getTile` at the middle of every cell of every kind of map, the layer moved; and two assertions that could not fail made to. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
GPU rendering of isometric, staggered and hexagonal maps under Added; its gain in percent under Performance, with the orthogonal figures for reference; the opacity change under Fixed; the tile layer fixes merged into six entries, those a game cannot see left out. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
…maps The Tiled feature line said orthogonal maps only, and that the others fell back to the CPU renderer. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
state.transition("mask", …, sprite), state.change(), then the usual
transition set back on the next line: that change hides and reveals with
the sprite's silhouette, and the next change is the usual fade.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
…nsition
state.transition("mask", …, sprite) let go of any sprite after one
transition, because a level's player is destroyed by the change. A sprite
that is in no level (atlas.createSpriteFromName(), kept by the game) or a
persistent one is not, and was dropped all the same: the first change
wore it, every later one was a plain iris, with nothing said.
A sprite shape, and a renderable center, are now let go only when the
change takes them: in the world, and not under a persistent child of it.
Anything else is kept with the transition and read again at each change.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
An offset given to a layer in Tiled moved a tile layer (since this release) and an image layer, and nothing else. An object layer's objects are now created that far from where they were drawn, collision shapes with them, and a group layer's offset moves the tile layers inside it, on top of their own. The objects are moved once they stand where their map puts them, so an isometric map's are moved on the screen, as Tiled does. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
…cond level The object layer carried an offset of (35, 1), one tile and a pixel, from a drag in the editor. The engine ignored object layer offsets until now, so the level was always played without it: cleared, the flies stay where they have always been. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
…es of the second level Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
A ParticleEmitter in world space follows each slime and drops flat blobs of its own purple along the base of the sprite, behind it. They stay where they fell, shrink and fade; under the slime they fill the strip between its body and the tile it walks on. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
The drops of the trail land where chance puts them, so the strip between the slime's body and the tile stayed open under its front. A bar of slime, as wide as the sprite and drawn behind it, now fills that strip from one end to the other; the drops are the trail it leaves behind. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
…e a trail The same as the built-in physics platformer: a bar of the slime's own purple under the whole sprite, filling the strip above the tile, and drops left behind that shrink and fade. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
A shader is bundled as text, and no minifier reads inside a string: every comment of every .vert, .frag and .wgsl file was in the published build and in every game made with it. They were two thirds of the shader text. stripShaderComments takes them out, keeping every line break so that a line of the result is the same line of the source file. The build uses it in an esbuild plugin, and the tests through vite-plugin-glsl's onComplete, so the tests compile the text that ships. The engine minifies to 1,073 kB from 1,159 kB, and to 323 kB gzipped from 350 kB. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
The Sprite and TextureAtlas docs said a normal map was "silently ignored" by the Canvas renderer and used by "the WebGL renderer". It is lit on WebGL and WebGPU, and Canvas draws the sprite unlit with a console warning, once, when lights are on. A video is refused with a TypeError; an animated sprite takes its normals from one static sheet laid out like its colour sheet. The alpha of a normal map masks the sprite's shininess, and a matte texel is still shaded by the direction under that alpha. Tests now draw it: from an image file, and from an ImageBitmap made with premultiplyAlpha "none", the highlight follows the alpha and the direction is kept at an alpha of 0. The lighting skill says which sources lose it (a canvas, an ImageBitmap made with the default options, a file whose transparent pixels a tool has cleared). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
pnpm audit reported 46 known vulnerabilities (1 critical, 24 high), all in development tools or in the private examples app; none in a dependency of a published package. It now reports none. Raised: vite 8.1.5 to 8.3.8, vitest and @vitest/browser 4.1.11 to 4.1.12, serve to 14.2.8, react-router-dom to 7.18.6. Overrides raised for shell-quote (the critical one, through concurrently), markdown-it and react-router, and added for minimatch, brace-expansion and fast-uri, which their parents have not picked up yet. eslint and typescript-eslint stay where they were: their newer versions add rules that flag 25 places in the engine, which is a change of its own. Only their minimatch is moved, by override. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
…linter points at Six places told TypeScript what a value was with a cast. They now find out, or no longer need to: - the built-in adapter looks for its own Body through one helper, and says so when a renderable has none; its 3D queries and the raycast check for the octree and for the body they walk, and pass over anything else - the audio listener asks its target whether it can say which way it faces - a mesh reverses its winding in one helper, on a copy the index array makes of itself, so of the same kind - the keyboard handlers take the key, and the browser's event when there is one: the browser's keyCode is read in one place - the particle setting that does nothing has no default any more These pass the current linter and the next one (typescript-eslint 8.73), which is not installed by this change. 55 tests added: 22 pin what is new, 33 guard what must not move. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
The engine's build script began with its own lint, and the workspace lint builds first, then lints every package: the engine was linted twice by pnpm lint, and a third time in CI by the test job's build. The build now only builds. The lint stays where it guards something: pnpm lint, and the release scripts and the publish workflow, which call it by name. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
pnpm lint ran ESLint once over the whole workspace, in one process that loads every package's types together. Each package now has a lint script (eslint .) and turbo runs them: a package that has not changed, and whose dependencies have not, is skipped, and a change to the lint configuration re-lints them all. The files at the root and the scaffolder, which have no package script, are linted by lint:root. The same 1003 files are linted as before, with the same result. Unchanged, the ESLint part of pnpm lint takes no time at all where it took about a minute; after editing one plugin it takes 6 seconds. It also keeps each process small: the next typescript-eslint needs about 3 GB to lint the whole workspace in one process, and no more than the engine alone needs today when each package has its own. Changelog: a Chore section for this and for the dependency update. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
In Cross Roads the floor runs over the top cell of a ladder: a wall cell of the IntGrid layer, and so a solid body, which stopped a player climbing down. A wall the ladder being climbed goes through no longer stops the player; inside it, read from the IntGrid layer, the player stays on the ladder: no stepping off sideways, no jump. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
One more jump in the air after leaving the ground, a ladder or the water, a little weaker than a jump from the ground, with its own blip and a puff under the feet. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
…x, not a fix Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
Registered in the LDtk Platformer and the LDtk Level Loader, as in the other examples. In the platformer it is on P: the panel's own key, S, is the one that climbs down. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
A tile layer with a boolean custom property `collider` set to true gets a static world shape for each run of its tiles, built with the wall code the LDtk reader uses. It is the property the Sprite Fusion editor writes in its TMX export for a layer checked as a collider, so one of its maps, which already loaded as a Tiled map, is now played as exported. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
…ADME A fixture in the form of the editor's TMX export checks what a game gets from one: the layers, the walls of the layers checked as colliders, and a tile's attributes, which the export writes as Tiled tile properties and the engine reads as any tile's, each value of its type. The tilemaps skill says how to load one. The README's list of tools has the editor's icon. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
An export made with the editor writes each attribute with its type, a string's included, and refuses a TMX export while per-tile instance attributes are on. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
…e properties One parser and one reader for a tile map, under three type names: "tmx", "tilemap" (the same, under a name that is not an editor's) and "spritefusion", which also loads the spritesheet.png saved next to the map, under a name of the map's own, and frees it with the map. The reader takes a map in the words of either editor, leaving the file's content as it is: Tiled's (width, tilewidth, a layer's data, properties) or Sprite Fusion's JSON export (mapWidth, tileSize, a layer's list of tiles and its collider switch, attributes). `attributes`, a plain object of values kept as written, is read wherever `properties` is. A placed tile's own attributes are kept on its cell: TileLayer#getCellProperties gives the properties of the tile in a cell (the tileset's, with the cell's own over them), setCellProperties gives a cell its own. A tile the map's tilesets do not have is left out of a layer given as a list, with a warning, rather than throwing at each draw. Tests: both exports of one map compared cell by cell, wall by wall and pixel by pixel on Canvas and WebGL, two maps each with its own spritesheet, unloading, odd and wrong files, cell properties. The asset type docs link each editor's home page. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
The shorter names for getCellProperties / setCellProperties, which were added in the previous commit and are not released: the column and row say it is a cell. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
… them The layer's two methods for the properties of the tile at a position are named getTileProperties and setTileProperties: "tile" is the engine's word. (They were added on this branch and are not released.) Pathfinding: Grid.fromTileLayer reads a tile's weight through the layer, so a weight given to one placed tile (a Sprite Fusion attribute in its JSON export) counts as the tileset's does. On an engine before 20.18 it reads the tileset, as before. The asset type documentation lists the file extensions each type takes. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
…for registerObject* Loader documentation: the asset descriptor lists every type with the files it takes and how the asset is read back, with a link to each editor; the module header says which types are levels and what a map brings with it; more examples (a level from each editor, base URLs, unloading). The level director, level.load, TMXTileMap and TMXLayer say what a map may be written in, Tiled's words or Sprite Fusion's. registerObjectClass and registerObjectFactory are now the functions themselves, documented for every kind of level; registerTiledObjectClass and registerTiledObjectFactory are the same functions under their older names, marked deprecated in the documentation (no console notice: published plugins call them). The engine, the examples and the skills use the new names. Skills: a section on levels from each map editor in the loading skill, the new names in the tile map, performance and migration skills. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
… odd names and unknown tiles Defects an independent review proved, each now covered by a test: - A Tiled tile layer with a custom property named `ratio` (the one an image layer takes) had its ratio vector replaced by the property: the Canvas draw never ended, WebGL drew nothing, and inside a group the map failed to load. The property now sets the layer's ratio; a value that is not a number is left out with a warning. A scrolling setting keeps the part a definition leaves out, refuses what is not a number, and the draw loop no longer starts on bounds that are not numbers. - An image layer's attributes were written back into the cached map and converted as properties from the second load on (an `eval:` text ran), and were dropped when the layer had no properties. They are read into an object of their own. - A "spritefusion" asset whose name holds `.`, `/`, `\` or `:` could not find its own spritesheet. - In a layer given as a list, a tile placed over another kept the first one's attributes. - getTileProperties threw for a tile no tileset has. Also: one helper for a cell's slot, the map types named once, one test for "drawn from the spritesheet"; tests for walls and pathfinding weights on a map that starts off 0 and for attributes reaching an object; the skill and the TSDoc corrected where the review found them wrong. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
…under neutral names The map renderers are the geometry of a tile map's cells for an orientation, whatever the map was made with (an LDtk level uses the orthogonal one), so they move from level/tiled/renderer/ to level/tilemap/renderer/ and lose the TMX prefix: TileMapRenderer (the base class), OrthogonalRenderer, IsometricRenderer, HexagonalRenderer, StaggeredRenderer, ObliqueRenderer. The five that were exported keep their old names (TMXRenderer, TMXOrthogonalRenderer, ...) as deprecated aliases of the same classes, as a value and as a type, so `instanceof` and annotations written with them go on working. Internal moves, no change of behaviour: the object registry (registerObjectClass, createLevelObject) and its built-in factories go to level/tilemap/, and the map parser, which serves "tmx", "tilemap" and "spritefusion", is parsers/tilemap.js. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
The code that draws a tile layer on the GPU draws any TileLayer, whatever
the map was made with, so it is no longer named after Tiled's layer class:
video/{webgl,webgpu}/renderers/tmxlayer/ become renderers/tilelayer/,
TMXLayerGPURenderer becomes TileLayerGPURenderer, the shaders are
tilelayer.vert, *-tilelayer.frag and tilelayer-*.wgsl, and the shared
orientation table is gpu/tilelayer_orientation.js. The identifiers, the
comments and the tests that carried the name follow.
Internal, with no change of behaviour: none of it is exported.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
…of Tiled names TMXTilesetGroup was an empty subclass of TilesetGroup: it is now the same class under its older name, deprecated like the map renderers' (a value and a type, so `instanceof` and annotations go on working). Internal, no change of behaviour: the registry builds an object with one function, createLevelObject (createTMXObject is gone); the opacity helper every kind of level uses lives with the code that places objects, and TMXUtils still hands it out; the parser's local names follow. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
The class behind the "tmx", "tilemap" and "spritefusion" asset types reads a Tiled map or a Sprite Fusion one, and is what level.getCurrentLevel() returns for all three: it is named TileMap. loader.getTileMap returns the parsed map of any of them. TMXTileMap and loader.getTMX stay as deprecated aliases: the same class (a value and a type) and the same function, so nothing that uses them changes. The engine, the tests, the examples and the skills use the new names. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
…e it A ColorLayer is a renderable, with a position and a size, but its draw ignored both and always cleared the whole view. With a finite size it now fills that rectangle where it is: one of the world when it does not float, one of the screen when it does. Left as it is built, it fills the canvas as before. Built as an object of a level (class `ColorLayer`, with a `color`), it fills the object's rectangle. The background color of an LDtk level that is one of several in a world is such a layer, and its background image a sprite beside it: the class the LDtk reader had for the two is gone. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
…n and size Every pixel of the frame is compared with what the numbers give, on Canvas and WebGL: 13 places (in the view, across each edge and corner, just outside, far away) by 9 sizes (a pixel, a line each way, the view exactly, one pixel more, far more), with the camera at several places, floating or not, by five anchor points, inside containers, as the position and the size change, among other layers by draw order, with edges between pixels and with a size of nothing. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
The box an entity with no registered class becomes drew the sprite of its tile itself, and freed it itself. It is now a Container, with the sprite as its child: the engine draws it, moves it, fades it and frees it with the box, and what a game adds to the box goes where it goes. Tests, on Canvas and WebGL: the box is where the entity is, of its size, by its top left corner, whatever its pivot and shape, in every fill mode; the sprite is its only child, at the place in the box the fill mode asks, and so in the world; an entity with no tile has no child; the level's objects are the boxes, not what they hold; moved, the box takes its tile with it; faded, the tile is not seen; a child a game adds is placed in the box; removed, nothing of it is left. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
LDtk's `Repeat` fill mode drew its tile again and again in a loop of its own. It is now a pattern of the renderer's, as an image layer that repeats is: the tile is cut from its tileset once, into an image of its own (a pattern repeats a whole image), the pattern is made when the tile is added to a scene and again when the GPU context comes back, and the texture the renderer made of it is freed with the tile. Tests, on Canvas and WebGL: the picture is the one LDtk shows in boxes of every shape and pivot (as before); the pattern starts at the box's corner, also once the box is moved by amounts that are no multiple of the tile; the renderer lets go of the tile's image when the box is removed. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
… ColorLayer as a level class Defects a second independent review found, each now covered by a test: - The registry's two type imports no longer resolved after its file moved: the settings and the map of a registered factory were typed `any`, and the type test passed whatever they were. The test now says they are not `any`. - The box of an LDtk entity with no class, a container since the last change, took part in the collision checks though it has no body. - ColorLayer could not be registered as a level class from TypeScript: its `(x, y, settings)` form is declared, takes a size written as text, and LDtk builds each level's color of a world with it. A layer with one side of a size and the other endless fills the canvas exactly. - A layer's `parallaxScale` property that cannot be one failed the load: it is left out with a warning, as the other scrolling properties are. A layer in a group layer lost its own `parallaxOrigin`; the origin Tiled gives a ratio now follows the ratio whatever gave it. - The opacity helper TMXUtils hands out was missing from the published declarations. Entities showing the same tile repeated share one image of it, cut once and freed with the last of them. Tests added for what none covered: the pattern made again when the GPU context comes back (and not for a box out of the scene), a level's color and image in a world. Skills corrected where the review found them wrong. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
This was referenced Nov 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds two level formats to the engine, LDtk and Sprite Fusion, next to Tiled. Nothing is a plugin: the three share one tile map core, one level director and one object registry, so a layer, a tileset, a collision body or a registered class works the same whatever editor the level comes from.
What is new for a game
.ldtkfile is an"ldtk"asset (separate level files, tilesets and background images load with it). One level or a whole world; tile, auto and IntGrid layers; entities built from registered classes, with their fields; level backgrounds; neighbours and the table of contents. Tile layers take the GPU tile path where the map allows it.map.jsonormap.tmxis a"spritefusion"asset; itsspritesheet.pngis loaded with it. The JSON is read as it is: the tile map reader takes Sprite Fusion's words (tileSize,mapWidth,tiles,attributes,collider) next to Tiled's.ratio, as on anImageLayer;layer.getTileProperties(col, row)/setTileProperties; acolliderlayer property makes a tile layer solid; a"tilemap"asset type for maps written by other tools; tile layers can be built in code (TileLayer,Tileset,TilesetGroup,PlacedTileLayer,mergeGridRects).registerObjectClass/registerObjectFactoryfor any editor;level.load(..., { objects })chooses which objects are built; an object carries its levelid.ColorLayer— given a size, it fills that rectangle where it is instead of the whole canvas (what an LDtk level's background colour uses in a world).pos, and reads aweightgiven to one placed tile.Names made neutral (old names kept)
The classes that belong to no editor lose their
TMXprefix. Each old name stays exported as the very same function or class, marked@deprecated since 20.18.0in the docs and types (no console notice):registerTiledObjectClass,registerTiledObjectFactoryregisterObjectClass,registerObjectFactoryTMXRenderer,TMXOrthogonalRenderer,TMXIsometricRenderer,TMXHexagonalRenderer,TMXStaggeredRendererTileMapRenderer,OrthogonalRenderer,IsometricRenderer,HexagonalRenderer,StaggeredRendererTMXTileMap,TMXTilesetGroupTileMap,TilesetGrouploader.getTMXloader.getTileMapFixes to existing behaviour
Seven older bugs found on the way, listed in the changelog: a floating tile layer that disappeared once the camera moved, two tilesets cut from one image at different tile sizes drawing the same tiles, a tile layer removed at run time keeping its GPU texture, a frame after a level load showing layers back to front, an ignored
renderModeproperty, a leaked viewport-resize handler per level load, and the TypeScript type of an asset'sdata.About the size
234 files, about 29.8k lines added. Roughly 60% of it is tests and their fixtures (LDtk's own sample projects, and Sprite Fusion maps written in the form of the editor's two exports). About 2,600 engine lines are moved rather than new: the tile map core, the map renderers, the object registry and the GPU tile layer renderers went from
level/tiled/andrenderers/tmxlayer/to neutral folders. Net growth of the engine source is under 4%.Examples, docs, skills
melonjs-tilemaps,melonjs-loading-assets,melonjs-camera-and-drawing,melonjs-20-migration,melonjs-performance,melonjs-plugins, and the router.packages/melonjs(20.18.0, unreleased) andpackages/pathfinding-plugin(1.1.1, unreleased).How it was tested
pnpm test: 539 files, 12,530 tests passed, 245 skipped (WebGPU, no adapter in the test container).pnpm lintpasses.pnpm docbuilds with 0 errors. Pathfinding plugin: 113 tests.master(20.17.0): every Tiled-based example (map loader with its 12 maps, platformer, Matter platformer, isometric dungeon, water overworld, and the three glTF levels that also go throughlevel.load) was run frame by frame on a controlled clock with scripted input, on both versions, on WebGL and Canvas. All frames are pixel-identical (237 WebGL, 231 Canvas), and so are the dumps of every object in the world.master's unchanged example code, still using the old names, gives the same result on the new engine.Not verified: WebGPU rendering (no adapter here) and sound by ear.
Type of change
Checklist
pnpm lintpasses)pnpm testpasses)pnpm build)Related issues
None.
🤖 Generated with Claude Code
https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6